package com.zrwl.poscloud.core.restapi.admin.baseInfo;
import com.zrwl.poscloud.core.annotion.AuthorityVerify.AuthorityVerify;
import com.zrwl.poscloud.core.annotion.OperationLogger.OperationLogger;
import com.zrwl.poscloud.commons.exception.ThrowableUtils;
import com.zrwl.poscloud.commons.utils.ResultUtil;
import com.zrwl.poscloud.commons.validator.group.Delete;
import com.zrwl.poscloud.commons.validator.group.GetList;
import com.zrwl.poscloud.commons.validator.group.Insert;
import com.zrwl.poscloud.commons.validator.group.Update;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.zrwl.poscloud.xo.service.UserServiceConfigService;
import com.zrwl.poscloud.xo.vo.UserServiceConfigVO;
/**
 * 产品配置 controller api类
 *
 * @author 刘思童 AutoGenerate
 * @date 2023-05-23
 */
@RestController
@Api(value = "产品配置相关接口", tags = {"产品配置相关接口"})
@RequestMapping("/userServiceConfig")
@Slf4j
public class UserServiceConfigRestApi {
    @Autowired
    private UserServiceConfigService userServiceConfigService;
    @AuthorityVerify
    @ApiOperation(value = "获取产品配置列表", notes = "获取产品配置列表", response = String.class)
    @PostMapping("/getList")
    public String getList(@Validated({GetList.class}) @RequestBody UserServiceConfigVO userServiceConfigVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取产品配置列表: {}", userServiceConfigVO);
        return ResultUtil.successWithData(userServiceConfigService.getPageList(userServiceConfigVO));
    }

    @AuthorityVerify
    @ApiOperation(value = "获取产品配置列表", notes = "获取产品配置列表", response = String.class)
    @PostMapping("/getAllList")
    public String getAllList(@Validated({GetList.class}) @RequestBody UserServiceConfigVO userServiceConfigVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("获取产品配置列表: {}", userServiceConfigVO);
        return ResultUtil.successWithData(userServiceConfigService.getAllList(userServiceConfigVO));
    }

    @AuthorityVerify
    @OperationLogger(value = "新增产品配置")    @ApiOperation(value = "新增产品配置", notes = "新增产品配置", response = String.class)
    @PostMapping("/add")
    public String add(@Validated({Insert.class}) @RequestBody UserServiceConfigVO userServiceConfigVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("新增产品配置: {}", userServiceConfigVO);
        return userServiceConfigService.add(userServiceConfigVO);
    }

    @AuthorityVerify
    @OperationLogger(value = "修改产品配置")    @ApiOperation(value = "修改产品配置", notes = "修改产品配置", response = String.class)
    @PostMapping("/edit")
    public String edit(@Validated({Update.class}) @RequestBody UserServiceConfigVO userServiceConfigVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("修改产品配置: {}", userServiceConfigVO);
        return userServiceConfigService.edit(userServiceConfigVO);
    }

    @AuthorityVerify
    @OperationLogger(value = "删除产品配置")    @ApiOperation(value = "删除产品配置", notes = "删除产品配置", response = String.class)
    @PostMapping("/delete")
    public String delete(@Validated({Delete.class}) @RequestBody UserServiceConfigVO userServiceConfigVO, BindingResult result) {
        ThrowableUtils.checkParamArgument(result);
        log.info("删除产品配置: {}", userServiceConfigVO);
        return userServiceConfigService.delete(userServiceConfigVO);
    }

}
